// Achievement by G3X / GeXeH - Enjoy
// Version 1.0

// Achievement: Bring out your camera 100 times.

local Value = achievements.GetValue( "Camera Man", "total", 0 )
local Status = false

local function Update()

	if (Value != 100) then
		// print("Check Started.\n")
		local ply = LocalPlayer()
		local weap = ply:GetActiveWeapon()

		if (!ValidEntity( ply )) then return end
		
		if ( ValidEntity( weap ) && weap:GetClass() == "gmod_camera" ) then

			if !Status then
				Status = true
				// print("Camera Started.\n")
				Value = math.Clamp( Value + 1, 0, 100 )
				achievements.SetValue( "Camera Man", "total", Value )
				achievements.Update( "Camera Man", Value / 100, Value .. "/100" )
			end
		else
			Status = false
			// print("Camera Ended.\n")
		end

		// print("Check Ended.\n")
	
	else
		timer.Destroy("Achievement.CameraMan")
	end

end

timer.Create("Achievement.CameraMan", 1, 0, Update)

achievements.Register( "Camera Man", "Bring out your camera 100 times.", "achievements/cameraman", Value / 100, Value .. "/100" )